//
//  WorkMainViewController.m
//  OAProject
//
//  Created by yhj on 2017/2/20.
//  Copyright © 2017年 cdnunion. All rights reserved.
//  工作主界面

#import "WorkMainViewController.h"
#import "ExamineViewController.h"
#import "TaskListViewController.h"
#import "ProjectListViewController.h"
#import "AddTaskViewController.h"
#import "WorkTableViewCell.h"

static NSString *tableViewCellIdentifier=@"UITableViewCellIdentifier";
@interface WorkMainViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView *workMainTableView;

@end

@implementation WorkMainViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.title=@"工  作";

    [self.view addSubview:self.workMainTableView];

}

-(UITableView *)workMainTableView
{
    if (!_workMainTableView)
    {
        _workMainTableView=[[UITableView alloc]initWithFrame:CGRectMake(0,0,APPW,APPH) style:UITableViewStylePlain];
        _workMainTableView.delegate=self;
        _workMainTableView.dataSource=self;
        _workMainTableView.backgroundColor=WhiteColor;
        _workMainTableView.tableFooterView=[UIView new];
        [_workMainTableView registerClass:[WorkTableViewCell class] forCellReuseIdentifier:tableViewCellIdentifier];
    }
    return _workMainTableView;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSArray *arrImage=@[@"examine",@"task",@"business",@"administration"];
    NSArray *arrTitle=@[@"审  批",@"任  务",@"业  务",@"行  政"];
    NSArray *arrDeTitle=@[@"岗位相关审批",@"近期任务",@"岗位相关",@"考勤、出差、请假、报销、调休"];

    WorkTableViewCell *cell=[[WorkTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:tableViewCellIdentifier];

    cell.selectionStyle=UITableViewCellSelectionStyleNone;

    cell.imageUrl.image=[UIImage imageNamed:arrImage[indexPath.row]];

    cell.nameLabel.text=arrTitle[indexPath.row];
    cell.nameLabel.textColor=DarkGreyColor;
    cell.nameLabel.font=Font_Number(18);

    cell.detailLabel.text=arrDeTitle[indexPath.row];
    cell.detailLabel.textColor=LightGreyColor;
    cell.detailLabel.font=Font_Number(13);

    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return kmargin*7;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
        if (indexPath.row==0)
        {
            // 审批

             [self.view makeToast:@"暂无" duration:.5 position:CSToastPositionCenter];
            
//            ExamineViewController *examineViewController=[ExamineViewController new];
//            examineViewController.hidesBottomBarWhenPushed=YES;
//            [self.navigationController pushViewController:examineViewController animated:NO];
        }
        else
            if (indexPath.row==1)
        {
            // 任务
            TaskListViewController *taskListViewController=[TaskListViewController new];
            taskListViewController.hidesBottomBarWhenPushed=YES;
            [self.navigationController pushViewController:taskListViewController animated:NO];
        }
        else
    {
        [self.view makeToast:@"暂无" duration:.5 position:CSToastPositionCenter];
    }
}

// 间隙置边
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{

    if ([tableView respondsToSelector:@selector(setSeparatorInset:)])
    {
        [tableView setSeparatorInset:UIEdgeInsetsZero];
    }

    if ([tableView respondsToSelector:@selector(setLayoutMargins:)])
    {
        [tableView setLayoutMargins:UIEdgeInsetsZero];
    }

    if ([cell respondsToSelector:@selector(setLayoutMargins:)])
    {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}


@end
